package com.bh.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bh.common.utils.DateUtils;
import com.bh.common.utils.SecurityUtils;
import com.bh.order.domain.JcOrderReceivingParty;
import com.bh.order.mapper.JcOrderReceivingPartyMapper;
import com.bh.order.service.IJcOrderReceivingPartyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 订单收发货方Service业务层处理
 *
 * @author slx
 * @date 2023-04-22
 */

@Service
public class JcOrderReceivingPartyServiceImpl extends ServiceImpl<JcOrderReceivingPartyMapper, JcOrderReceivingParty> implements IJcOrderReceivingPartyService {
    @Autowired
    private JcOrderReceivingPartyMapper jcOrderReceivingpartyMapper;

    /**
     * 查询订单收发货方
     *
     * @param id 订单收发货方主键
     * @return 订单收发货方
     */
    @Override
    public JcOrderReceivingParty selectJcOrderReceivingpartyById(Long id) {
        return jcOrderReceivingpartyMapper.selectById(id);
    }

    /**
     * 查询订单收发货方列表
     *
     * @param jcOrderReceivingparty 订单收发货方
     * @return 订单收发货方
     */
    @Override
    public List<JcOrderReceivingParty> selectJcOrderReceivingpartyList(JcOrderReceivingParty jcOrderReceivingparty) {
        return jcOrderReceivingpartyMapper.selectJcOrderReceivingpartyList(jcOrderReceivingparty);
    }

    @Override
    public List<JcOrderReceivingParty> selectJcOrderReceivingpartyListByOrderId(Long orderId) {
        JcOrderReceivingParty jcOrderReceivingparty = new JcOrderReceivingParty();
        jcOrderReceivingparty.setJcOrderId(orderId);
        return jcOrderReceivingpartyMapper.selectJcOrderReceivingpartyList(jcOrderReceivingparty);
    }

    /**
     * 新增订单收发货方
     *
     * @param jcOrderReceivingparty 订单收发货方
     * @return 结果
     */
    @Override
    public int insertJcOrderReceivingparty(JcOrderReceivingParty jcOrderReceivingparty) {
        jcOrderReceivingparty.setCreateName(SecurityUtils.getUsername());
        jcOrderReceivingparty.setCreateTime(DateUtils.getNowDate());
        return jcOrderReceivingpartyMapper.insert(jcOrderReceivingparty);
    }

    /**
     * 修改订单收发货方
     *
     * @param jcOrderReceivingparty 订单收发货方
     * @return 结果
     */
    @Override
    public int updateJcOrderReceivingparty(JcOrderReceivingParty jcOrderReceivingparty) {
        return jcOrderReceivingpartyMapper.updateById(jcOrderReceivingparty);
    }

    /**
     * 批量删除订单收发货方
     *
     * @param ids 需要删除的订单收发货方主键
     * @return 结果
     */
    @Override
    public int deleteJcOrderReceivingpartyByIds(Long[] ids) {
        return jcOrderReceivingpartyMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除订单收发货方信息
     *
     * @param id 订单收发货方主键
     * @return 结果
     */
    @Override
    public int deleteJcOrderReceivingpartyById(Long id) {
        return jcOrderReceivingpartyMapper.deleteById(id);
    }
}
